package com.gym.code.config.admin.bean.method;

import com.gym.code.generator.EnumContants.EnumIdAware;
import com.gym.code.generator.EnumContants.MethodOperateType;

/**
 * 
 * @author xinchun.wang 
   @email: 532002108@qq.com
 * @createTime 2015-5-23 下午8:48:14
 */
public class MethodBaseMappingBean {

	protected long id;
	
	protected long tableId;
	/**
	 * 方法名字
	 */
	protected String functionName;
	
	/**
	 * 方法操作类型
	 */
	protected MethodOperateType methodOperateType = MethodOperateType.select;
	
	/**
	 * 参数是bean 还是分开的        参数
	 */
	protected MethodParameterCombineType methodParameterType = MethodParameterCombineType.fixedParamter;
	
	protected MethodResultType methodResultType = MethodResultType.update;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getTableId() {
		return tableId;
	}

	public void setTableId(long tableId) {
		this.tableId = tableId;
	}

	public String getFunctionName() {
		return functionName;
	}

	public void setFunctionName(String functionName) {
		this.functionName = functionName;
	}

	
	public MethodOperateType getMethodOperateType() {
		return methodOperateType;
	}

	public void setMethodOperateType(MethodOperateType methodOperateType) {
		this.methodOperateType = methodOperateType;
	}
	
	
	public void setMethodOperateType(int methodOperateType) {
		this.methodOperateType = MethodOperateType.getById(methodOperateType);
	}

	public MethodParameterCombineType getMethodParameterType() {
		return methodParameterType;
	}

	public void setMethodParameterType(
			MethodParameterCombineType methodParameterType) {
		this.methodParameterType = methodParameterType;
	}
	
	
	public void setMethodParameterType(int methodParameterType) {
		this.methodParameterType = MethodParameterCombineType.getById(methodParameterType);
	}

	public MethodResultType getMethodResultType() {
		return methodResultType;
	}

	public void setMethodResultType(MethodResultType methodResultType) {
		this.methodResultType = methodResultType;
	}

	public void setMethodResultType(int methodResultType) {
		this.methodResultType = MethodResultType.getById(methodResultType);
	}


	/**
	 * 方法参数的类型：分开的，或者 bean
	 * @author xinchun.wang 
	   @email: 532002108@qq.com
	 * @createTime 2015-4-26 下午3:19:49
	 */
	public static enum MethodParameterCombineType implements EnumIdAware {
		fixedParamter(0), beanParameter(1);

		private MethodParameterCombineType(int id) {
			this.id = id;
		}

		public static MethodParameterCombineType getById(int id) {
			for (MethodParameterCombineType item : values()) {
				if (item.getId() == id) {
					return item;
				}
			}
			return null;
		}

		protected int id;

		public int getId() {
			return this.id;
		}
	}
	
	
	/**
	 * 方法返回的四种结果：其中除了select 之外，其他都是更新操作
	 * @author xinchun.wang 
	   @email: 532002108@qq.com
	 * @createTime 2015-5-23 下午4:24:00
	 */
	public static enum MethodResultType implements EnumIdAware {
		update(0),select_bean(1), select_bean_list(2),select_map(3);

		private MethodResultType(int id) {
			this.id = id;
		}

		public static MethodResultType getById(int id) {
			for (MethodResultType item : values()) {
				if (item.getId() == id) {
					return item;
				}
			}
			return null;
		}

		private int id;

		public int getId() {
			return this.id;
		}
	}
}
